package com.ruixi.spring.usermod.service.impl;

import com.ruixi.spring.usermod.dao.UserDao;
import com.ruixi.spring.usermod.dao.UserDaoImpl;
import com.ruixi.spring.usermod.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    //原始写法
    //private UserDao userDao = new UserDaoImpl();

    @Autowired
    @Qualifier(value = "userDaoMybatisImpl")   //该注解和Autowired配合使用,用于如果有多个匹配自动装配条件的bean时,指定一个进行装配,value中定义的是指定的生成的bean的id
    private UserDao userDao;

    public UserServiceImpl() {
        System.out.println("UserServiceImpl");
    }

    @Override
    public void addUser() {
        this.userDao.addUser();
    }
}
